home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / c / agl103p.lha / src / agl / sprite.c < prev    next >
C/C++ Source or Header  |  1994-12-08  |  3KB  |  119 lines

  1. /******************************************************************************
  2.  
  3. Copyright © 1994 Jason Weber
  4. All Rights Reserved
  5.  
  6. $Id: sprite.c,v 1.2.1.3 1994/12/09 05:29:56 jason Exp $
  7.  
  8. $Log: sprite.c,v $
  9.  * Revision 1.2.1.3  1994/12/09  05:29:56  jason
  10.  * added copyright
  11.  *
  12.  * Revision 1.2.1.2  1994/11/16  06:29:47  jason
  13.  * added NOT_EXTERN check
  14.  *
  15.  * Revision 1.2.1.1  1994/03/29  05:41:32  jason
  16.  * Added RCS Header
  17.  *
  18.  * Revision 1.2.1.1  2002/03/26  22:04:22  jason
  19.  * Added RCS Header
  20.  *
  21.  * Revision 1.2.1.1  2002/03/26  22:00:51  jason
  22.  * RCS/agl.h,v
  23.  *
  24.  
  25. ******************************************************************************/
  26.  
  27.  
  28. #ifndef NOT_EXTERN
  29. #include"agl.h"
  30. #endif
  31.  
  32. #define SPRITESPACE    4
  33. #define SPRITELINES    7
  34.  
  35. struct SimpleSprite MouseSprite;
  36.  
  37. UBYTE *SpriteChip;
  38.  
  39. UBYTE SpriteData[SPRITESPACE*SPRITELINES]=
  40.     {
  41.     0,0, 0,0,    /* position,control */
  42.  
  43.     0x20,0x00,0x00,0x00,
  44.     0x20,0x00,0x00,0x00,
  45.     0xF8,0x00,0x00,0x00,
  46.     0x20,0x00,0x00,0x00,
  47.     0x20,0x00,0x00,0x00,
  48.  
  49.     0,0, 0,0,    /* end */
  50.     };
  51.  
  52. long SpriteID= -1;
  53.  
  54.  
  55.  
  56. /******************************************************************************
  57. void    create_mousesprite(void)
  58.  
  59. ******************************************************************************/
  60. /*PROTOTYPE*/
  61. void create_mousesprite(void)
  62.     {
  63.     SpriteChip=AllocMem(SPRITESPACE*SPRITELINES,MEMF_CHIP);
  64.     memcpy(SpriteChip,SpriteData,SPRITESPACE*SPRITELINES);
  65.  
  66.     SpriteID=GetSprite(&MouseSprite,3);
  67.     if(SpriteID!=3)
  68.         {
  69.         GL_error("Error creating mouse sprite");
  70.         SpriteID= -1;
  71.         return;
  72.         }
  73.  
  74.     MouseSprite.height=SPRITELINES-2;
  75.  
  76.     SetRGB4(GLView,21,15,0,0);
  77.     SetRGB4(GLView,22,0,15,0);
  78.     SetRGB4(GLView,23,0,0,15);
  79.  
  80.     ChangeSprite(GLView,&MouseSprite,SpriteChip);
  81.     printf("Sprite Created\n");
  82.  
  83.     move_mousesprite(0,0);
  84.     }
  85.  
  86.  
  87. /******************************************************************************
  88. void    move_mousesprite(long mx,long my)
  89.  
  90. ******************************************************************************/
  91. /*PROTOTYPE*/
  92. void move_mousesprite(long mx,long my)
  93.     {
  94.     static long lastx= -1,lasty= -1;
  95.  
  96.     if(mx!=lastx || my!=lasty)
  97.         {
  98.         WaitBOVP(GLView);
  99.         MoveSprite(GLView,&MouseSprite,mx-6,GLScreen->Height-my-5);
  100. /*         printf("Sprite Moved %d %d\n",mx,my); */
  101.  
  102.         lastx=mx;
  103.         lasty=my;
  104.         }
  105.     }
  106.  
  107.  
  108. /******************************************************************************
  109. void    free_mousesprite(void)
  110.  
  111. ******************************************************************************/
  112. /*PROTOTYPE*/
  113. void free_mousesprite(void)
  114.     {
  115.     FreeSprite(SpriteID);
  116.     FreeMem(SpriteChip,SPRITESPACE*SPRITELINES);
  117.     printf("Sprite Freed\n");
  118.     }
  119.